package com.bykj.taketurns.activity;

import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import com.bykj.taketurns.R;
import com.bykj.taketurns.widget.CommonVideoView;


/**
 * Created by Administrator on 2016/8/8.
 */
public class WidthMatchVideo extends Activity {

    private String uri;
    private String videoPath;
    private int videoid;
    private CommonVideoView videoView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_widthmatchvideo);
        videoPath = getIntent().getStringExtra("videoPath");

        videoid = getIntent().getIntExtra("videoid", 0);
        Log.d("logresult", videoid + "");


        if (videoid == 0) {
            uri = videoPath;
        }

        videoView = (CommonVideoView) findViewById(R.id.common_videoView);
        videoView.start(uri);

        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.linearlayout);
        linearLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            videoView.setFullScreen();
        } else {
            videoView.setNormalScreen();
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        finish();
    }
}
